package demo.thread;

public class ThreadTest {
    static int a = 0;

    public static void main(String[] args) throws InterruptedException {
        method1();
    }

    private static void method1() throws InterruptedException {
        for (int i = 0; i < 2; i++)
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    for (int j = 0; j < 100; j++) {
//                        synchronized (ThreadTest.class) {
                            a++;
//                        }
                    }
                }
            }).start();
        ;
        Thread.sleep(2500);
        System.out.println("a=" + a);
    }

    ;
}
